
uniform sampler2DRect scene;
uniform float HighlightThreshold;

float luminance(vec3 c)
{
	return dot( c, vec3 (0.3, 0.59, 0.11) );
}

float highlights(vec3 c, in float HighlightThreshold)
{
	return smoothstep(HighlightThreshold, 1.0, luminance(c.rgb));
}

void main ()
{
	vec4 c  = texture2DRect(scene, gl_TexCoord[0].st);
	c.a = highlights(c.rgb,HighlightThreshold);	
	gl_FragColor = c;
}
